package com.huitone.smspfm;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Configurator;
import org.springframework.data.redis.core.RedisTemplate;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Response;

import com.bin.common.utils.FileUtils;
import com.bin.common.utils.StringUtils;
import com.huitone.smspfm.context.utils.ContextUtils;
import com.huitone.smspfm.core.config.AppStaticConfigs;
import com.huitone.smspfm.dao.oracle.SmSignDao;
import com.huitone.smspfm.dao.oracle.entity.SmSign;


public class MyTest {

	
//	static {
//		try {
//			String path = Thread.currentThread().getContextClassLoader().getResource("log4j2.xml").getPath().substring(1).replace("/", "\\\\");
//			Configurator.initialize(null, new ConfigurationSource(new FileInputStream(path)));
//
////			Configurator.initialize(null, new ConfigurationSource(new FileInputStream(System.getProperty("log4j2.xml"))));
//		} catch (Exception e) {
//			System.out.println("初始化log4j2配置文件错误");
//		}
//	}
//	MyTest.class.getClassLoader().getResourceAsStream("lua/getforbid.lua");
	
	public static void main(String[] args) throws FileNotFoundException{
		
		testUnChar();
		
//		String name = System.getProperty("os.name");
//		System.out.println(name);
//		int m = name.indexOf("Window");
//		System.out.println(m);
//		String str1 = "﻿abc";
//		str1 += str1;
//
//		str1 = str1.replaceAll("\\p{C}", "");
//        System.out.println(str1.substring(0,1));
//        System.out.println(str1);
//        System.out.println(str1.length());
//        byte[] charBt = str1.getBytes();
//        System.out.println(charBt.length);
////        System.out.println(String.valueOf(charBt[0]).hashCode());
////        System.out.println(String.valueOf(charBt[1]).hashCode());
////        System.out.println(String.valueOf(charBt[2]).hashCode());
////        System.out.println(String.valueOf(charBt[3]).hashCode());
//		
//		String str = "14679996";
//		Boolean isChinese = true;// [\u4e00-\u9fa5] [\u0391-\uFFE5]
//		String chinese = "[\u4e00-\u9fa5]";
//		if (!StringUtils.isEmpty(str)) {
//			// 获取字段值的长度，如果含中文字符，则每个中文字符长度为2，否则为1
//			for (int i = 0; i < str.length(); i++) {
//				// 获取一个字符
//				String temp = str.substring(i, i + 1);
//				// 判断是否为中文字符
//				if (temp.matches(chinese)) {
//				} else {
//					isChinese = false;
//				}
//			}
//		}
//		
//		System.out.println(isChinese);
		
		
		
//		System.out.println(MyTest.class.getClassLoader().getResource("lua/getforbid.lua"));
//		String path = MyTest.class.getClassLoader().getResource("lua/getforbid.lua").getPath().substring(1).replace("/", "\\\\");
//		System.out.println(path);
//		StringBuffer sb = FileUtils.read(new FileInputStream(path));
//		
//		System.out.println(sb.toString());
//		
//		
//		
//		Jedis jedis = new Jedis("172.16.7.24", 10001);
//		
//		Pipeline p = jedis.pipelined();
//		
//		p.hset("ou123".getBytes(), "ou12343333".getBytes(), "ou144234578".getBytes());
//		String key = "testRedis1";
//		Map<String,Double> map = new HashMap<String,Double>();
//		map.put("aaa", (double) 123131);
//		map.put("cccc", (double) 223131);
//		
//		p.zadd(key, map);
//		
//		
//		List<Object> syncAndReturnAll = p.syncAndReturnAll();
////		Response<byte[]> bt = p.hget("ou123".getBytes(), "ou1234".getBytes());
//		System.out.println(syncAndReturnAll.size());
//		jedis.close();
//		
		
		

		
	}
	
	public static void testUnChar(){
		String path = "C:\\Users\\Administrator\\Desktop\\charText.txt";
		File f = new File(path);
		BufferedReader in = null;
		StringBuffer sb = new StringBuffer();
		
		try {
			in = new BufferedReader(new InputStreamReader(
					new FileInputStream(path), "UTF-8"));
			String str = "";
			while ((str = in.readLine()) != null) {
				if(!"".equals(str) && ! System.lineSeparator().equals(str)){ 
					sb.append(str);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		if(!StringUtils.isEmpty(sb)){
			
			String text = sb.toString();
			System.out.println(text.length());
			text = text.replaceAll("[^\u0020-\u9FA5]", "");
			System.out.println(text);
			System.out.println(text.length());
		}
	
	}
	
	
}
